package com.example.demo.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo.entity.warehouse;
import com.example.demo.service.WarehouseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


@RestController
@RequestMapping("warehouse")
@CrossOrigin
@Api(tags="仓库类操作",value="仓库类操作")
public class Warehouse {
    @Resource
   WarehouseService WarehouseService;
    @PostMapping("/query")
    @ApiOperation(value = "查询",notes = "返回仓库中组件信息")
    public List warehouse(@RequestBody warehouse warehouse){return WarehouseService.warehouse(warehouse);
    }
    @PostMapping("/update")
    @ApiOperation(value ="修改仓库信息",notes = "输入comename和comsign修改该条信息")
    public String updatewarehouse(@RequestBody warehouse warehouse){
        return WarehouseService.update(warehouse);
    }
    @PostMapping("/delete")
    @ApiOperation(value = "删除仓库信息",notes = "输入comname和comsign删除该条信息")
    public String deletewarehouse(@RequestBody warehouse warehouse){
        return WarehouseService.delete(warehouse);
    }
    @PostMapping("/page")
    @ApiOperation(value = "分页显示仓库信息",notes = "输入页码和条数显示第几页和条数")
    public List<warehouse> getList() {
        Page<warehouse> page = new Page<>(1,5);//分页设置current：页码 size：每页数据条数
        Page<warehouse> warehousePage = WarehouseService.page(page, null);//分页显示
        return warehousePage.getRecords();//返回数据记录
    }
}
